#include "DatagramPackage.h"

DatagramPackage::DatagramPackage(char* data, unsigned int length) {
    this->data = data;
    this->offset = 0;
    this->length = length;

    this->address = "127.0.0.1";
    this->port = 0;
}

DatagramPackage::DatagramPackage(char* data, unsigned int length, const char* address) {
    this->data = data;
    this->offset = 0;
    this->length = length;

    this->address = address;
    this->port = 0;
}

DatagramPackage::DatagramPackage(char* data, unsigned int offset, unsigned int length) {
    this->data = data;
    this->offset = offset;
    this->length = length;

    this->address = "127.0.0.1";
    this->port = 0;
}

DatagramPackage::DatagramPackage(char* data, unsigned int offset, unsigned int length, const char* address) {
    this->data = data;
    this->offset = offset;
    this->length = length;

    this->address = address;
    this->port = 0;
}

DatagramPackage::DatagramPackage(char* data, unsigned int offset, unsigned int length, const char* address, unsigned short port) {
    this->data = data;
    this->offset = offset;
    this->length = length;

    this->address = address;
    this->port = port;
}

DatagramPackage::~DatagramPackage() {
}

const char * DatagramPackage::getAddress() {
    return this->address;
}

void DatagramPackage::setAddress(const char *address) {
    this->address = address;
}

unsigned short DatagramPackage::getPort() {
    return this->port;
}

void DatagramPackage::setPort(unsigned short port) {
    this->port = port;
}

char * DatagramPackage::getData() {
    return this->data;
}

void DatagramPackage::setData(char* data) {
    this->data = data;
    this->offset = 0;
    this->length = sizeof(data);
}

void DatagramPackage::setData(char *data, unsigned int offset, unsigned int length) {
    this->data = data;
    this->offset = offset;
    this->length = length;
}

unsigned int DatagramPackage::getOffset() {
    return this->offset;
}

unsigned int DatagramPackage::getLength() {
    return this->length;
}
